package com.network.service;

import java.util.ArrayList;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.network.dao.IUserDAO;
import com.network.entity.Page;
import com.network.entity.User;
import com.network.entity.UserQryHelper;

/**
 * 
 * @author Ling Xiaowei
 *
 */
@Component
public class UserServiceImpl implements IUserService{
	
	private IUserDAO userDAO;
	@Transactional
	public void saveOrUpdateUser(User user) {
		userDAO.saveOrUpdateUser(user);
	}
	@Transactional
	public void deleteUser(User user) {
		userDAO.deleteUser(user);
	}
	@Transactional
	public User getUserById(String id) {
		if(id == null)
		{
			return null;
		}
		return userDAO.getUserById(id);
	}
	@Transactional
	public void deleteUserById(String id) {
		userDAO.deleteUserById(id);
	}

	public IUserDAO getUserDAO() {
		return userDAO;
	}
	
	@Resource(name="userDAOImpl")
	public void setUserDAO(IUserDAO userDAO) {
		this.userDAO = userDAO;
	}
	@Transactional
	public boolean isUsernameExisted(String id) {
		// TODO Auto-generated method stub
		return userDAO.isUsernameExisted(id);
	}
	@Transactional
	public ArrayList<User> qryUser(Page p, UserQryHelper helper)
	{
		return userDAO.loadUser(p, helper);
	}

}
